fix: remove flush() in _write_frame to prevent hang on USB CDC ACM#77
Closed
jirogit wants to merge 1 commit into
Closed
fix: remove flush() in _write_frame to prevent hang on USB CDC ACM#77jirogit wants to merge 1 commit into
jirogit wants to merge 1 commit into
Conversation
serial.flush() calls termios.tcdrain() under the hood, which blocks indefinitely on USB CDC ACM devices (e.g. ESP32 T3S3/S3 with TinyUSB) on Linux. Confirmed on Linux Mint + T3S3 + MeshCore KISS Modem v1.15.0. pyserial's write() already copies data into the kernel USB buffer atomically, so no explicit drain is needed.
Author
|
Closing: could not reliably reproduce the hang on T3S3. Reproduction conditions are unclear — the installed venv had already been manually patched, and pymc-repeater ran normally with flush() present. Reopening if a reliable reproduction case is identified. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
serial.flush()callstermios.tcdrain()internally, which blocks indefinitely on USB CDC ACM devices (e.g. ESP32 T3S3/S3 with TinyUSB) on Linuxpyserial'swrite()already copies data into the kernel USB buffer atomically — no explicit drain is neededRoot Cause
pyserial'sSerial.flush()callstermios.tcdrain()on POSIX systems. For native UART devicestcdrain()returns promptly, but USB CDC ACM character devices (backed by TinyUSB on ESP32) do not implement thetcdraincompletion signal, causing it to hang indefinitely.Fix
Replace the
flush()try/except block with a comment explaining why it was removed:Test Plan
/dev/ttyACM0)KissModemWrapper.connect()and verify it no longer hangs in_write_frame()/dev/ttyUSB0with CH340/CP2102)Tested: